tools/lib/api/fs/fs.c: Fix misuse of strncpy()
authorBen Hutchings <ben@decadent.org.uk>
Thu, 19 Jul 2018 22:36:52 +0000 (23:36 +0100)
committerSalvatore Bonaccorso <carnil@debian.org>
Sun, 19 Jan 2020 09:22:58 +0000 (09:22 +0000)
commit382a752afe786fedf9d85dbe06131ae1310ed9e8
treef9e5e221f1630e6d38878fc9982e2e3d77915031
parent1ca03a43e8ee01a3b16f88027ef63b1ebfec821c
tools/lib/api/fs/fs.c: Fix misuse of strncpy()

Bug-Debian: https://bugs.debian.org/897802
Forwarded: https://lore.kernel.org/lkml/20180721021026.GQ14131@decadent.org.uk/T/

gcc 8 reports:

In function 'fs__env_override',
    inlined from 'fs__get_mountpoint' at fs/fs.c:228:6:
fs/fs.c:222:2: error: 'strncpy' specified bound 4096 equals destination size [-Werror=stringop-truncation]
  strncpy(fs->path, override_path, sizeof(fs->path));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'm not convinced it makes sense to truncate the copied string here,
but since we're already doing so let's ensure it's still null-
terminated.  Use strlcpy() instead.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name tools-lib-api-fs-fs.c-fix-misuse-of-strncpy.patch
tools/lib/api/fs/fs.c